import { useReducer, createContext } from 'react'
import App from '../App'

const initState = {
    city: '武汉'
}
const reducer = (state, action) => {
    switch (action.type) {
        case 'chooseCity':
            console.log(action.city.name);
            return { city: action.city.name }
        default:
            return initState
    }
}

export const Context = createContext();
export const Provider = props => {
    const [state, dispath] = useReducer(reducer, initState);
    return (
        <Context.Provider value={[state, dispath]}>
            <App />
        </Context.Provider>
    )
}